#include <iostream>
#include <unistd.h>

//多进程demo
int main(){
    std::cout<< "fork\n" << std::endl;

    pid_t childPid;
    childPid = fork();
    if(childPid < 0){
        std::cout<< "fork failed\n" << std::endl;
    }else if(childPid == 0){
        //子进程
        printf("im child getpid=:%d\n", (int)getpid());
    }else{
        //father
        printf("im father getpid=:%d, fork=%d\n", (int)getpid(), childPid);
    }

    return 0;
}